#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++) 
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int , int >;
using vec = vector < int >;
using veg = vector < pii >;

int read() {
	int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-', ch = getchar(); 
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar(); return f ? -x : x;
}

ll dfs(ll a, ll b, ll c, int t) {
	if(t == 5) return 0;
	ll res = 0;
	ll v = a / 5; res = max(res, dfs(a - v * 5, b, c, t + 1) + v);
	v = min(a, c / 2); res = max(res, dfs(a - v, b, c - v * 2, t + 1) + v);
	v = min(a / 2, b / 2); res = max(res, dfs(a - v * 2, b - v * 2, c, t + 1) + v);
	v = min(a / 3, c); res = max(res, dfs(a - v * 3, b, c - v, t + 1) + v);
	v = min(b / 2, c); res = max(res, dfs(a, b - 2 * v, c - v, t + 1) + v);
	return res;
}

void solve() {
	ll a, b, c;
	cin >> a >> b >> c;
	ll ans = dfs(a, b, c, 1);
	cout << ans << endl;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	for(int T = in; T; T--) solve();
	return 0;
}
